from flask import Blueprint
from flask_restful import Api
from utils.constants import BASE_URL_PRIFIX
from .articles import  ArticleListResource,ArticleDetailResource
# 1.创建蓝图对象
article_bp = Blueprint('article', __name__, url_prefix=BASE_URL_PRIFIX)

# 2.创建Api对象
article_api = Api(article_bp)

# 设置json包装格式
from utils.output import output_json
article_api.representation('application/json')(output_json)

from .channel import AllChangelResource
article_api.add_resource(AllChangelResource,'/channels')

article_api.add_resource(ArticleListResource, '/articles')
article_api.add_resource(ArticleDetailResource, '/articles/<int:article_id>')

from .following import FollowUserResource,UnFollowUserResource
article_api.add_resource(FollowUserResource,'/user/followings')
article_api.add_resource(UnFollowUserResource, '/user/followings/<int:target>')

from .comment import CommentsResource
article_api.add_resource(CommentsResource, '/comments')